package com.hebeu.group.controller;

import com.hebeu.group.pojo.Otable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hebeu.group.service.TableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 餐桌控制器
 */
@Controller
@RequestMapping("/tables")
public class TableController {

    private TableService tableService;

    @Autowired
    public TableController(TableService tableService) {
        this.tableService = tableService;
    }

    /**
     * 查看桌子列表
     *
     * @return
     */
    @RequestMapping("/queryAllTables.action")
    @ResponseBody
    public List<Otable> queryAllOtables() {
        List<Otable> tableList = tableService.selectAllTable();
        return tableList;
    }

    /**
     * 通过id查询餐桌
     *
     * @param tableId
     * @return
     */
    @RequestMapping(value = "/queryTablesByTabld.action")
    @ResponseBody
    public Object queryTablesByTabld(int tableId) {
        Otable table = tableService.selectSingleTable(tableId);
        return table;
    }

    /**
     * 查询所有营业商家
     * @return
     */
    @RequestMapping("/queryNoStatusTables.action")
    @ResponseBody
    public List<Otable> queryNoStatusTables() {
        return tableService.selectNoStatusTable();
    }

    /**
     * 查询所有服务中的餐桌
     * @return
     */
    @RequestMapping("/queryStatusTables.action")
    @ResponseBody
    public List<Otable> queryStatusTables() {
        return tableService.selectStatusTable();
    }

    /**
     * 通过id查询餐桌名称
     *
     * @param tableId
     * @return
     */
    @RequestMapping(value = "/queryTablesNameByTabId.action")
    @ResponseBody
    public String queryTablesNameByTabId(int tableId) {
        String tableName = tableService.selectTablesNameByTabId(tableId);
        return tableName;
    }
}

